<template>
    <div>
        <!-- pc -->
        <div class="wrap" v-if="innerWidth > 500">
            <div class="fixed u-flex">
                <img class="hand img" src="@/image/index/back.png" @click="back">
                <img src="@/image/russia/logo2.png" class="logo">
                俄数通
            </div>
            <div class="fixed_hei"></div>

            <!-- 返回顶部按钮 -->
            <div class="top u-flex-center hand" @click="scrollToTop">
                <img src="@/image/russia/top.png" alt="">
            </div>

            <!-- 列表 -->
            <div class="table info">
                <div class="u-flex tit">
                    <img src="@/image/russia/enterprise.png" alt="">
                    企业信息
                </div>
                <div class="center u-flex">
                    <div class="left">
                        <img :src="detail.image_url" alt="">
                        <!-- <div class="data flex flex-x-between">
                        <div>交易次数：11</div>
                        <div>访问次数：11</div>
                    </div> -->
                    </div>
                    <div class="right">
                        <img src="@/image/russia/ab1.png" class="img1">
                        <img src="@/image/russia/ab2.png" class="img2">

                        <div class="u-flex right_item">
                            <div class="item_left">交易次数</div>
                            <div class="item_right">{{ detail.money_num }}次</div>
                        </div>
                        <div class="u-flex right_item">
                            <div class="item_left">中国供应商占比</div>
                            <div class="item_right">{{ detail.china_store_percentage }}%</div>
                        </div>
                        <div class="u-flex right_item">
                            <div class="item_left">全球供应商</div>
                            <div class="item_right">{{ detail.global_store }}家</div>
                        </div>
                        <div class="u-flex right_item">
                            <div class="item_left">向俄罗斯出口</div>
                            <div class="item_right">{{ detail.china_percentage }}%</div>
                        </div>
                        <div class="u-flex right_item">
                            <div class="item_left">数据获取年限</div>
                            <div class="item_right">{{ detail.acquisition_time }}</div>
                        </div>
                    </div>
                </div>
                <div class="foot">
                    <div v-html="content" style="font-size: 0;"></div>
                </div>
            </div>
        </div>
        <!-- 手机端 -->
        <div v-else class="pho">
            <PhoHead topIndex="det"></PhoHead>
            <!-- 列表 -->
            <div class="white">
                <div class="u-flex tit">
                    <img src="@/image/russia/enterprise.png" alt="">
                    企业信息
                </div>
                <div class="tab u-flex">
                    <div class="left">
                        <img :src="detail.image_url" v-if="detail.image_url">
                    </div>
                    <div class="right u-flex">
                        <div class="name">
                            <div class="name_item">交易次数</div>
                            <div class="name_item">中国供应商占比</div>
                            <div class="name_item">全球供应商</div>
                            <div class="name_item">向俄罗斯出口</div>
                            <div class="name_item">数据获取年限</div>
                        </div>
                        <div class="cont">
                            <img src="@/image/russia/report/detBg.png" class="bg">
                            <div class="cont_item">{{ detail.money_num }}次</div>
                            <div class="cont_item">{{ detail.china_store_percentage }}%</div>
                            <div class="cont_item">{{ detail.global_store }}家</div>
                            <div class="cont_item">{{ detail.china_percentage }}%</div>
                            <div class="cont_item">{{ detail.acquisition_time }}</div>
                        </div>
                    </div>
                </div>
                <div class="foot">
                    <div v-html="content" style="font-size: 0;"></div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import {
    useStore
} from 'vuex';
export default {
    data() {
        return {
            // 正在加载
            isLoading: false,
            detail: {},
            articleId: "",
            content: '',
            innerWidth: 0,
        }
    },
    mounted() {
        // 从查询参数中获取 userId
        this.articleId = this.$route.query.id;
        // 获取信息列表
        this.getCategoryList()
        this.innerWidth = window.innerWidth
    },
    created() {
        this.store = useStore();
    },
    methods: {
        // 获取信息列表
        getCategoryList() {
            this.store.dispatch("home/articleDetApi", {
                articleId: this.articleId
            }).then(res => {
                if (res.status == 200) {
                    this.detail = res.data.detail

                    let richtext = this.detail.content;
                    const regex = new RegExp('<img', 'gi');
                    this.content = richtext.replace(regex, '<img style="width:100%;"')
                }
            })
        },
        back() {
            this.$router.go(-1);
        },
        scrollToTop() {
            window.scrollTo({
                top: 0,
                behavior: "smooth", // 可选：平滑滚动效果
            });
        },
    }
}
</script>
<style lang="less" scoped>
@media screen and (max-width: 1850px) {
    .table {
        padding: 25px 15px 30px !important;

        .tit {
            margin-bottom: 15px !important;

            img {
                width: 20px !important;
            }
        }

        .center {
            padding: 30px 0 !important;

            .left {
                margin-right: 40px !important;
            }

            .right {
                font-size: 14px !important;

                .img2 {
                    width: 90px !important;
                    top: -25px !important;
                }
            }
        }
    }
}


@media screen and (max-width: 1650px) {
    .info {
        width: 1240px !important;
    }

    .table {

        .tit {
            margin-bottom: 13px !important;
            font-size: 13px !important;

            img {
                width: 18px !important;
            }
        }

        .center {

            .left {
                margin-right: 36px !important;
            }

            .right {

                .img2 {
                    width: 85px !important;
                }
            }
        }
    }
}


@media screen and (max-width: 1500px) {
    .info {
        width: 1100px !important;
    }

    .fixed {
        font-size: 16px !important;

        .img {
            width: 11px !important;
        }

        .logo {
            width: 40px !important;
            margin: 0 16px !important;
        }
    }

    .table {
        padding: 20px 15px 30px !important;

        .tit {
            margin-bottom: 13px !important;
            font-size: 12px !important;

            img {
                width: 16px !important;
            }
        }

        .center {
            padding: 25px 0 !important;

            .left {
                margin-right: 34px !important;

                .data {
                    font-size: 10px !important;
                    padding: 8px !important;
                }
            }

            .right {
                font-size: 10px;

                .img2 {
                    width: 70px !important;
                    top: -20px !important;
                }
            }
        }

        .foot {
            padding: 30px 150px 0 !important;
        }
    }
}

@media screen and (max-width: 1366px) {
    .info {
        width: 1000px !important;
    }

    .fixed {
        font-size: 14px !important;

        .img {
            width: 10px !important;
        }

        .logo {
            width: 35px !important;
            margin: 0 14px !important;
        }
    }

    .top {
        width: 40px !important;
        height: 40px !important;
    }

    .table {

        .center {

            .right {
                font-size: 12px !important;
            }
        }
    }
}

@media screen and (max-width: 1250px) {
    .info {
        width: 900px !important;
    }

    .table {
        .center {

            .right {
                font-size: 11px !important;

                .img2 {
                    width: 60px !important;
                }
            }
        }
    }
}


@media screen and (max-width: 1150px) {
    .info {
        width: 800px !important;
    }

    .table {

        .center {
            padding: 20px 0 !important;

            .right {
                font-size: 10px !important;

                .img2 {
                    width: 60px !important;
                }

                .item_left {
                    padding: 0 0 0 15px !important;
                }

                .item_right {
                    padding: 0 10px !important;
                }
            }
        }

        .foot {
            padding: 20px 100px 0 !important;
        }
    }
}

@media screen and (max-width: 1000px) {
    .info {
        width: 700px !important;
    }

    .table {

        .center {

            .left {
                margin-right: 24px !important;
            }

            .right {
                font-size: 9px !important;

                .img2 {
                    width: 50px !important;
                    top: -18px !important;
                }

                .item_left {
                    padding: 0 0 0 10px !important;
                }
            }
        }
    }
}

@media screen and (max-width: 900px) {
    .info {
        width: 650px !important;
    }
}

.wrap {
    min-height: 100vh;
    // padding: 0 14%;
    background: #F7F8FA;
}

.fixed {
    width: 100%;
    position: fixed;
    font-size: 20px;
    color: #333;
    height: 60px;
    line-height: 60px;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1;
    padding: 0 56px;
    background-color: #fff;
    box-shadow: 0px 2px 2px 1px rgba(0, 0, 0, 0.16);

    .img {
        width: 13px;
        margin-right: 6px;
    }

    .logo {
        width: 45px;
        margin: 0 20px;
    }
}

.fixed_hei {
    height: 80px;
}

.top {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #fff;
    position: fixed;
    bottom: 100px;
    right: 50px;

    img {
        width: 50%;
        height: auto;
    }
}

.info {
    width: 1440px;
    margin: 0 auto;
}

.table {
    background: #fff;
    padding: 33px 24px 49px;
    box-sizing: border-box;
    box-shadow: 0px 3px 6px 1px rgba(0, 0, 0, 0.16);

    .tit {
        margin-bottom: 20px;

        img {
            width: 24px;
            margin-right: 6px;
            font-size: 18px;
        }
    }

    .center {
        padding: 41px 0;
        border-top: 1px solid #CCC;
        border-bottom: 1px solid #CCC;

        .left {
            width: 30%;
            aspect-ratio: 16/11;
            margin-right: 46px;
            border: 1px solid #CCC;
            position: relative;
            overflow: hidden;

            img {
                width: 100%;
                height: 100%;
            }

            .data {
                position: absolute;
                bottom: 0;
                width: 100%;
                font-size: 14px;
                padding: 12px;
            }
        }

        .right {
            flex: 1;
            aspect-ratio: 16/4.9;
            position: relative;
            border: 1px solid #ccc;

            .img1 {
                width: 80%;
                position: absolute;
                bottom: 0;
                right: 0;
            }

            .img2 {
                width: 100px;
                top: -30px;
                right: -10px;
                position: absolute;
            }

            .right_item {
                height: 20%;
                border-bottom: 1px solid #ccc;

                &:last-child {
                    border-bottom: none;
                }
            }

            .item_left {
                width: 19.5%;
                height: 100%;
                padding: 0 0 0 20px;
                display: flex;
                align-items: center;
                background: #EDF4FF;
                border-right: 1px solid #ccc;
            }

            .item_right {
                padding: 0 20px;
                flex: 1;
                display: flex;
                align-items: center;
                flex-wrap: wrap;

                .item_right_data {
                    margin-right: 20px;
                }
            }
        }
    }

    .foot {
        padding: 59px 190px 0;

        img {
            width: 100%;
        }
    }
}

// 手机端
.pho {


    .white {
        padding: 0px 10px 10px;
        background: #fff;

        .tit {
            padding: 13px 0;

            img {
                width: 24px;
                margin-right: 6px;
                font-size: 18px;

            }
        }

        .tab {
            border-top: 2px solid #ccc;
            border-bottom: 2px solid #ccc;
            padding: 15px 0;

            .left {
                width: 110px;
                height: 140px;
                margin-right: 10px;
                border: 1px solid #CCC;

                img {
                    width: 100%;
                    height: 100%;
                    object-fit: cover;
                }
            }

            .right {
                width: calc(100% - 120px);
                height: 140px;
                font-size: 12px;
                border: 1px solid #CCC;

                .name {
                    width: 50%;
                    height: 100%;
                    background: #EDF4FF;

                    .name_item {
                        height: 20%;
                        display: flex;
                        align-items: center;
                        padding-left: 10px;
                        border-bottom: 1px solid #ccc;
                        border-right: 1px solid #ccc;

                        &:last-child {
                            border: none;
                            border-right: 1px solid #ccc;
                        }
                    }
                }

                .cont {
                    width: 50%;
                    height: 100%;
                    position: relative;

                    .cont_item {
                        height: 20%;
                        display: flex;
                        align-items: center;
                        padding-left: 10px;
                        border-bottom: 1px solid #ccc;

                        &:last-child {
                            border: none;
                        }
                    }

                    .bg {
                        width: 100%;
                        position: absolute;
                        bottom: 0;
                        right: 0;
                    }
                }
            }
        }

        .foot {
            margin-top: 15px;
        }
    }
}
</style>